<!--{if $totalpage>$_G[page]}-->
<script>
    var finished = false;
    var totalpage = {$totalpage};
    var cur_page = {$_G[page]};
    $(function(){
        $(window).scroll(function(){
            //var scrollTop = document.documentElement.scrollTop || window.pageYOffset || document.body.scrollTop;
            var scrollTop = $(window).scrollTop();
            var owinH = $(window).height();
            var odocH = $(document).height();

            if((scrollTop + owinH + 120>= odocH) && !finished){
                cur_page++;
                finished = true;

                if(totalpage<cur_page){return false;}
                $("#loading").show();
                $.ajax({
                    url:'{$pageurl}&ajax=1',
                    data:{
                        page:cur_page
                    }
                })
                    .success(function(l) {

                        $("#loading").hide();
                        $("#ajaxlist").append(l.substring(l.indexOf("<!-- more pagelist start -->"), l.indexOf("<!-- more pagelist end -->")));
                        imgdelay();
                        if($('.popup').length > 0) {
                            popup.init();
                        }
                        if(totalpage<=cur_page){
                            $("#ajaxlist").append('<div class="loadingend">{$lang[loadingend]}</div>');
                        }
                        finished = false;


                    })
                    .error(function() {


                    });

                return false;
            }

        });
    });



</script>
<div id="loading" style="display:none;">
	<div class="box">
		<img src="{STRONGDIR}/touch/images/page_load.gif">
		<span>{echo $lang[loading]}</span>
	</div>
</div>
<!--{/if}-->